﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_StaffPages_StaffUpdateCompetition : System.Web.UI.Page
{
    int cId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        cId = Convert.ToInt32(Request.QueryString["cId"].ToString());
        ManagerBUS manager = new ManagerBUS();
        Competition c = manager.searchCompetitionById(cId);
        txtNameCompetition.Text = c.Name;
        txtFirstPrize.Text = c.FirstPrize;
        txtSecondPrize.Text = c.SecondPrize;
        txtThreePrize.Text = c.ThirdPrize;
        txtPostDateComeptition.Text = c.PostDate;
        txtStartDateCompetition.Text = c.StartDate;
        txtEndDateCompetition.Text = c.EndDate;
        txtDescriptionUpdateCompetition.Text = c.Description;
        txtQuotationUpdateCompetition.Text = c.Quotation;
    }
    protected void btnUpdateCompetition_Click(object sender, EventArgs e)
    {
        ManagerBUS manager = new ManagerBUS();
        Competition c = manager.searchCompetitionById(cId);
        c.ComId = cId;
        c.Name = txtNameCompetition.Text;
        c.FirstPrize = txtFirstPrize.Text;
        c.SecondPrize = txtSecondPrize.Text;
        c.ThirdPrize = txtThreePrize.Text;
        c.PostDate = txtPostDateComeptition.Text;
        c.StartDate = txtStartDateCompetition.Text ;
        c.EndDate= txtEndDateCompetition.Text;
        c.Description= txtDescriptionUpdateCompetition.Text;
        c.Quotation= txtQuotationUpdateCompetition.Text;
        if (manager.updateCompetition(c))
        {
            Response.Redirect("~/Pages/HomePage/Success.aspx");
        }
        else
        {
            lblWarning.Text = "Failed";
        }
    }
}